<div class="page-header position-relative">
	<h1>
		Kiểu Sản Phẩm
	</h1>
	
</div><!--/.page-header-->
<div>
	<div class="pull-right">
		<div class="widget-toolbar">				
			<a href="<?php echo Yii::app()->createUrl('store/backend/subsubcategory/create'); ?>" role="button" class="white" data-toggle="modal"  title="Add new subsubcategory">
				<i class="icon-plus"></i>
			</a>
		</div>
	</div>
</div>
<div class="row-fluid">
	<div class="table-header">
		Tất Cả Kiểu Sản Phẩm
		
	</div>

	<table id="sample-table-2" class="table table-striped table-bordered table-hover">
		<thead>
			<tr>
				<th class="center">
					<label>
						<input type="checkbox" />
						<span class="lbl"></span>
					</label>
				</th>				
				<th>Kiểu Sản Phẩm</th>
				<th>Loại Danh Mục</th>
				<th class="hidden-480">Ngày Tạo</th>

				<th class="hidden-phone">
					<i class="icon-time bigger-110 hidden-phone"></i>
					Ngày Cập Nhật
				</th>
				<th>Trạng Thái</th>
				<th>Hành Động</th>
			</tr>
		</thead>

		<tbody>
			<?php foreach($data as $subsubcategory) : ?>
			<tr>
				<td class="center">
					<label>
						<input type="checkbox" />
						<span class="lbl"></span>
					</label>
				</td>

				<td>
					<a href="#"><?php echo $subsubcategory->SubSubCateName; ?></a>
				</td>
				<td><?php echo $subsubcategory->subcate->SubCateName;?></td>
				
				<td><?php echo date_format(new DateTime($subsubcategory->CreateDate),'F jS Y'); ?></td>
				
				<td class="hidden-480"><?php if($subsubcategory->UpdateDate !== '') echo date_format(new DateTime($subsubcategory->UpdateDate),'F jS Y');?></td>
				<td class="hidden-phone">
					<?php 
					if($subsubcategory->Status) 
						echo '<span class="label label-success arrowed">Kích hoạt</span>';
					else 
						echo '<span class="label label-success arrowed">Không kích hoạt</span>';
					?>
				</td>
				<td class="td-actions">
					<div class="hidden-phone visible-desktop action-buttons">

						<a class="green" href="<?php echo Yii::app()->createUrl('store/backend/subsubcategory/update',array('id' => $subsubcategory->SubSubCateId)); ?>">
							<i class="icon-pencil bigger-130"></i>
						</a>

						<a class="red" href="javascript:void(0)" onclick="delete_image(<?php echo $subsubcategory->SubSubCateId ?>)">
							<i class="icon-trash bigger-130"></i>
						</a>
					</div>

					<div class="hidden-desktop visible-phone">
						<div class="inline position-relative">
							<button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown">
								<i class="icon-caret-down icon-only bigger-120"></i>
							</button>

							<ul class="dropdown-menu dropdown-icon-only dropdown-yellow pull-right dropdown-caret dropdown-close">

								<li>
									<a href="<?php echo Yii::app()->createUrl('store/backend/subsubcategory/update',array('id' => $subsubcategory->SubSubCateId)); ?>" class="tooltip-success" data-rel="tooltip" title="Edit">
										<span class="green">
											<i class="icon-edit bigger-120"></i>
										</span>
									</a>
								</li>

								<li>
									<a href="#" class="tooltip-error" data-rel="tooltip" title="Delete">
										<span class="red">
											<i class="icon-trash bigger-120"></i>
										</span>
									</a>
								</li>
							</ul>
						</div>
					</div>
				</td>
			</tr>
			<?php endforeach; ?>
		</tbody>
	</table>
</div>
<script type="text/javascript">
	function delete_image(id){
		var checkstr =  confirm('Bạn có chắc chắn muốn xóa KIỂU SẢN PHẨM này không?');
		if(checkstr == true){
			$.ajax({
				url: '<?php echo Yii::app()->createUrl("store/backend/subsubcategory/delete/");?>',
				type: 'POST',
				dataType: 'json',
				data: {id:id},
				success: function(){
					alert('Bạn đã xóa thành công');
					window.location.reload();
				},
				error: function(){
					alert('Vui lòng kiểm tra lại xem có sản phẩm nào hay loại danh mục nào có chứa KIỂU SẢN PHẨM này không?');
				}
			});
		}else{
			return false;
		}
		
	}
</script>